package example.neon;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

import static util.Util.getRealFile;

public class MainJFrameNeon extends JFrame {
    public static JPanelImgAndMsgContent jPanelImgAndMsgContent = new JPanelImgAndMsgContent();

    public static JPanelSettingContent jPanelSettingContent = new JPanelSettingContent();

    public MainJFrameNeon() {
        JPanel jPanelAll = new JPanel();
        jPanelAll.setLayout(new BoxLayout(jPanelAll, BoxLayout.Y_AXIS));
        jPanelAll.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 20));

        JPanelCollapse jPanelCollapseSetting = new JPanelCollapse("配置", jPanelSettingContent, false);
        jPanelAll.add(jPanelCollapseSetting);

        JPanelCollapse jPanelCollapseImg = new JPanelCollapse("图像识别", jPanelImgAndMsgContent, true);
        jPanelAll.add(jPanelCollapseImg);

        this.getContentPane().add(jPanelAll);

        JPanel jPanel = new JPanel();
        jPanel.setLayout(new BorderLayout());
        jPanel.setBorder(BorderFactory.createEmptyBorder(100, 100, 100, 100));
        this.getContentPane().add(jPanel);

        this.setTitle("霓虹深渊-自动钓鱼");
        // 设置layout
        this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
        // 隐藏工具栏
//        this.setUndecorated(true);
//        this.setOpacity(0.5f);
        // 设置边框
        this.setBounds(760, 20, 310, 500);
        this.setVisible(true);
        // 窗口置顶
        this.setAlwaysOnTop(true);
        //
        this.setResizable(false);
        //
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        try {
            BufferedImage image = ImageIO.read(getRealFile("img/neon/icon.png"));
            this.setIconImage(image);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
    }

    public static void main(String[] args) throws Exception {
        MainJFrameNeon test = new MainJFrameNeon();
    }
}
